import request from '@/config/request'
import type { LessonSearchForm, LessonPostForm } from '@/config/forms'

export default {
    getList: (form : LessonSearchForm) => request.post('/backend/lessons', form),
    getItem: (id : number) => request.get('/backend/lessons/' + id),
    create: (form : LessonPostForm) => request.post('/backend/lessons/', form),
    update: (id : number, form : LessonPostForm) => request.post('/backend/lessons/' + id, form),
    getContent: (id: number) => request.get('/backend/lessons/' + id + '/content'),
    updateContent: (id: number, content: string) => request.post('/backend/lessons/' + id + '/content', {content}),
    delete: (id : number) => request.delete('/backend/lessons/' + id),
    recommend: (ids : number[], status: boolean) => request.post('/backend/lessons/recommend', {ids, status}),
    onself: (ids : number[], status: boolean) => request.post('/backend/lessons/onself', {ids, status}),
    getStudyLog: (lessonId: number, page: number, limit: number) => request.get('/backend/educations/lesson', {params: {lessonId, page, limit}}),
    getDetailStudyLog: (lessonId: number, page: number, limit: number) => request.get('/backend/educations/lesson/logs', {params: {lessonId, page, limit}}),
}